package com.kmfc.user.web;

import com.kmfc.user.dao.UsersDO;
import com.kmfc.user.service.UserService;
import com.kmfc.user.web.vo.ArticlesDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;
    @Autowired
    private RestTemplate restTemplate;

    /**
     * @description：获取用户信息
     * @param： id 用户id
     * @return：用户
     * @date: 2025-03-09 21:37:16
     * @author： yuzhonghong
     */
    @GetMapping("/{id}")
    public ArticlesDO queryById(@PathVariable("id") Integer id) {
        log.info("id，【{}】", id);

        //远程调用
        //String url = "http://localhost:8082/articles/" + id;
        String url = "http://articleservice/articles/" + id;
        ArticlesDO articlesDO = restTemplate.getForObject(url, ArticlesDO.class);

        return articlesDO;
        //return userService.selectByPrimaryKey(id);
    }


}
